/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.qlangtech.tis.plugin.datax.common;

import com.qlangtech.tis.datax.IDataxProcessor.TableMap;
import com.qlangtech.tis.datax.SourceColMetaGetter;
import com.qlangtech.tis.extension.Describable;
import com.qlangtech.tis.extension.TISExtensible;
import com.qlangtech.tis.plugin.datax.CreateTableSqlBuilder;
import com.qlangtech.tis.plugin.datax.CreateTableSqlBuilder.ColWrapper;
import com.qlangtech.tis.sql.parser.visitor.BlockScriptBuffer;

import java.io.Serializable;

/**
 * @author: 百岁（baisui@qlangtech.com）
 * @create: 2024-12-18 09:18
 **/
@TISExtensible
public abstract class AutoCreateTableColCommentSwitch implements Describable<AutoCreateTableColCommentSwitch>, Serializable {


    public abstract boolean turnOn();


    /**
     * 添加标准的列注释，当然小部分目标端例如oracle不支持这种方式添加列注释
     * clickhouse:
     * <pre>
     *     CREATE TABLE employees (
     *     employee_id UInt32 COMMENT '员工的唯一标识符',
     *     first_name String COMMENT '员工的名字',
     *     last_name String COMMENT '员工的姓氏',
     *     email String COMMENT '员工的电子邮件地址，用作公司内部通信' DEFAULT '',
     *     phone_number String COMMENT '员工的联系电话' DEFAULT '',
     *     hire_date Date COMMENT '员工加入公司的日期',
     *     job_id String COMMENT '员工职位的标识符，对应于jobs表中的job_id',
     *     salary Float64 COMMENT '员工每月的基本工资',
     *     commission_pct Float32 COMMENT '基于销售额的提成比例',
     *     manager_id Nullable(UInt32) COMMENT '直接上级经理的employee_id',
     *     department_id Nullable(UInt32) COMMENT '员工所属部门的标识符'
     * ) ENGINE = MergeTree()
     * ORDER BY employee_id;
     * </pre>
     * <p>
     *
     * @param sourceColMetaGetter
     * @param tableMapper
     * @param colWrapper
     * @param ddlScript
     */
    public abstract void addStandardColComment(
            SourceColMetaGetter sourceColMetaGetter, TableMap tableMapper, ColWrapper colWrapper, BlockScriptBuffer ddlScript);

    /**
     * Oracle(create table DDL 中不能出现添加列注释的内容要分开):
     * <pre>
     *     -- 创建 employees 表
     * CREATE TABLE employees (
     *     employee_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, -- 员工ID，自动生成
     *     first_name  VARCHAR2(50) NOT NULL,                               -- 员工的名字
     *     last_name   VARCHAR2(50) NOT NULL,                               -- 员工的姓氏
     *     email       VARCHAR2(100) NOT NULL UNIQUE,                       -- 员工的电子邮件地址，唯一
     *     phone_number VARCHAR2(20),                                       -- 员工的电话号码
     *     hire_date   DATE NOT NULL,                                       -- 雇佣日期
     *     job_id      VARCHAR2(10) NOT NULL,                               -- 工作ID，关联到job表
     *     salary      NUMBER(8,2),                                         -- 薪水，允许两位小数
     *     commission_pct NUMBER(4,2),                                      -- 提成百分比，允许两位小数
     *     manager_id  NUMBER,                                              -- 经理ID，可能为空
     *     department_id NUMBER                                             -- 部门ID，可能为空
     * );
     *
     * -- 分别为每个字段添加注释
     * COMMENT ON COLUMN employees.employee_id IS '员工的唯一标识符';
     * COMMENT ON COLUMN employees.first_name IS '员工的名字';
     * COMMENT ON COLUMN employees.last_name IS '员工的姓氏';
     * COMMENT ON COLUMN employees.email IS '员工的电子邮件地址，用作公司内部通信';
     * COMMENT ON COLUMN employees.phone_number IS '员工的联系电话';
     * COMMENT ON COLUMN employees.hire_date IS '员工加入公司的日期';
     * COMMENT ON COLUMN employees.job_id IS '员工职位的标识符，对应于jobs表中的job_id';
     * COMMENT ON COLUMN employees.salary IS '员工每月的基本工资';
     * COMMENT ON COLUMN employees.commission_pct IS '基于销售额的提成比例';
     * COMMENT ON COLUMN employees.manager_id IS '直接上级经理的employee_id';
     * COMMENT ON COLUMN employees.department_id IS '员工所属部门的标识符';
     * </pre>
     *
     * @param createTableSqlBuilder
     * @param colMetaGetter
     * @param tableMapper
     * @param script
     */
    public void addOracleLikeColComment(CreateTableSqlBuilder<ColWrapper> createTableSqlBuilder
            , SourceColMetaGetter colMetaGetter, TableMap tableMapper, BlockScriptBuffer script) {
    }

}
